package com.example.love_margin.Mapper.configuer;

import com.example.love_margin.Entity.Search;
import org.apache.ibatis.jdbc.SQL;

public class upOneSearch {

    public String UpOnePet(Search search){
        return new SQL() {
            {
                UPDATE("search");
                if (search.getSearch_pet_name() != null) {
                    SET("search_pet_name = #{search_pet_name}");
                }
                if (search.getSearch_pet_class() != null) {
                    SET("search_pet_class = #{search_pet_class}");
                }
                if (search.getSearch_pet_sex() != null) {
                    SET("search_pet_sex = #{search_pet_sex}");
                }
                if (search.getSearch_pet_area() != null) {
                    SET("search_pet_area = #{search_pet_area}");
                }
                if (search.getSearch_pet_category() != null) {
                    SET("search_pet_category = #{search_pet_category}");
                }
                if (search.getSearch_pet_varieties() != null) {
                    SET("search_pet_varieties = #{search_pet_varieties}");
                }
                if (search.getSearch_pet_age() != null) {
                    SET("search_pet_age = #{search_pet_age}");
                }
                if (search.getSearch_pet_message() != null) {
                    SET("search_pet_message = #{search_pet_message}");
                }
                if (search.getSearch_pet_state() != null) {
                    SET("search_pet_state = #{search_pet_state}");
                }
                if (search.getSearch_pet_contact() != null) {
                    SET("search_pet_contact = #{search_pet_contact}");
                }
                if (search.getUser_id() != null) {
                    SET("user_id = #{user_id}");
                }
                WHERE("search_id= #{search_id}");
            }
        }.toString();
    }

}
